﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>店铺资料</title>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/ydui.css?v=1.1.4" rel="stylesheet" />
    <script src="../js/ydui.flexible.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/all.css?v=20180302" />
    <style type="text/css">
        .m-cell .cell-left{width:80px;}
        .m-cell-img .m-uploader li .desp {
            width: 100%;
            height: 0.35rem;
            line-height: 0.35rem;
            background: #363636;
            position: absolute;
            bottom: 0;
            left: 0;
            font-size: 0.25rem;
            opacity: 0.4;
        }
        .m-cell:after{border:none;}
    </style>
</head>
<body ms-controller="userset" class="ms-controller">
    <div class="page-group">
        <div class="page page-current" id="rounter">
            <div class="g-flexview">
                <header class="m-navbar">
                    <a onclick="history.back()" class="navbar-item"><i class="back-ico"></i></a>
                    <div class="navbar-center"><span class="navbar-title">店铺资料</span></div>
                </header>
                <div class="g-scrollview">
                    <p style="font-size: .25rem;color:#ff8a00;padding:0.5rem 0.2rem;background-color:#fff;margin-top:5px;margin-bottom:5px;">
                        <i class="iconfont icon-xuanzhong"></i>
                        注：请真实填写店铺基本资料，向会员宣传展示。
                    </p>
                    <div class="m-celltitle">店铺展示图<span style="float:right;">1-4张</span></div>
                    <div class="m-cell m-cell-img">
                        <div class="m-uploader">
                            <ul>
                                <li ms-for="($index,el) in @FileData">
                                    <img ms-attr="{src:ComFunJS.FilePath(el,'/100/100')}" />
                                    <span class="delete" ms-on-tap="@DelFile(el,1)">×</span>
                                </li>
                                <li ms-if="@FileData.length<4">
                                    <span class="add">+</span>
                                    <input type="file" class="upload-input" onchange="upload(this,1)" accept="image/jpeg,image/jpg,image/png">
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="m-cell">
                        <div class="cell-item">
                            <div class="cell-left">店铺分类</div>
                            <label class="cell-right cell-arrow">
                                <select class="cell-select" ms-duplex="@ModelData.Type1">
                                    <option value="">请选择分类</option>
                                    <option ms-for="el in @TypeData" ms-attr="{value:el.ID}">{{el.TypeName}}</option>
                                </select>
                            </label>
                        </div>
                        <div class="cell-item">
                            <div class="cell-left">店铺名称</div>
                            <div class="cell-right">
                                <input type="text" class="cell-input" placeholder="请输入店铺名称" ms-duplex="@ModelData.Title" />
                            </div>
                        </div>
                        <div class="cell-item">
                            <div class="cell-left">店铺描述</div>
                            <div class="cell-right">
                                <input type="text" class="cell-input" placeholder="请输入店铺描述" ms-duplex="@ModelData.Desp" />
                            </div>
                        </div>
                        <div class="cell-item">
                            <div class="cell-left">联系人</div>
                            <div class="cell-right">
                                <input type="text" class="cell-input" placeholder="请输入联系人" ms-duplex="@ModelData.Contact" />
                            </div>
                        </div>
                        <div class="cell-item">
                            <div class="cell-left">联系电话</div>
                            <div class="cell-right">
                                <input type="text" class="cell-input" placeholder="请输入联系电话" ms-duplex="@ModelData.ContactTel" />
                            </div>
                        </div>
                        <div class="cell-item">
                            <div class="cell-left">位置</div>
                            <div class="cell-right">
                                <input type="text" class="cell-input" placeholder="请输入店铺位置" ms-duplex="@ModelData.Address" />
                            </div>
                        </div>                  
                      
                    </div>
                    <div class="m-celltitle">营业执照</div>
                    <div class="m-cell m-cell-img">
                        <div class="m-uploader">
                            <ul>
                                <li ms-if="@ModelData.License">
                                    <img ms-attr="{src:ComFunJS.FilePath(@ModelData.License,'/100/100')}" />
                                    <span class="delete" ms-on-tap="@DelFile('',3)">×</span>
                                </li>
                                <li ms-if="!@ModelData.License">
                                    <span class="add">+</span>
                                    <input type="file" class="upload-input" onchange="upload(this,3)" accept="image/jpeg,image/jpg,image/png">
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="m-celltitle">店铺简介<span style="float:right;">200字以内</span></div>
                    <div class="m-cell">
                        <div class="cell-item">
                            <div class="cell-right">
                                <textarea class="cell-textarea" placeholder="请输入店铺简介" ms-duplex="@ModelData.Summary" style="height:3rem;"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="m-celltitle">店铺产品图片<span style="float:right;">1-8张</span></div>
                    <div class="m-cell m-cell-img">
                        <div class="m-uploader">
                            <ul>
                                <li ms-for="($index,el) in @FileData2">
                                    <img ms-attr="{src:ComFunJS.FilePath(el,'/100/100')}" />
                                    <span class="delete" ms-on-tap="@DelFile(el,2)">×</span>
                                </li>
                                <li ms-if="@FileData2.length<8">
                                    <span class="add">+</span>
                                    <input type="file" class="upload-input" onchange="upload(this,2)" accept="image/jpeg,image/jpg,image/png">
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div ms-if="@ModelData.ID!=0">
                        <p style="font-size: .25rem;color:#ff8a00;padding:0.5rem 0.2rem;background-color:#fff;margin-top:5px;margin-bottom:5px;">
                            <i class="iconfont icon-xuanzhong"></i>
                            <span ms-if="@ModelData.Status==0">正在审核</span>
                            <span ms-if="@ModelData.Status==1">审核通过</span>
                            <span ms-if="@ModelData.Status==9">审核不通过，请重新提交</span>
                        </p>
                    </div>
                   
                    <a class="btn  btn-primary tabbar-item" style="width:95%;margin:0.2rem;color:#fff;" ms-on-tap="@Save()" ms-if="@ModelData.Status!=0">
                        提交
                    </a>
                </div>
               
               
            </div>
        </div>


    </div>
    <script src="https://cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script>
    <script src="../js/ydui.js"></script>
    <script src="../js/avalon.mobile.min.js"></script>
    <script src="../js/ComFunJS.js?v=20180331"></script>
    <script src="../js/lrz/lrz.all.bundle.js"></script>
    <script>

        var model = avalon.define({
            $id: "userset",
            ModelData: { "ID": 0, "Type1": "", "Title": "", "Desp": "", "ImgUrl": "", "Contact": "", "ContactTel": "", "Address": "", "Status": "-1", "ImgUrl2": "", "Summary": "", "License": "" },
            FileData: [],
            FileData2:[],
            DelFile: function (el, s) {
                if (s == 1) {
                    model.FileData.remove(el);
                } else if (s == 2) {
                    model.FileData2.remove(el);
                } else if (s == 3) {
                    model.ModelData.License = "";
                }
            },
            TypeData: [],
            GetTypeData: function () {
                $.getJSON("/api/base/cate/list/2/0", function (r) {
                    if (r.error == "") {
                        model.TypeData = r.result;
                    }
                })
            },
            GetListData: function () {
                YDUI.dialog.loading.open("努力加载中...");
                $.getJSON("/api/user/vd/model", function (r) {
                    YDUI.dialog.loading.close();
                    if (r.error == "" && r.result) {
                        model.ModelData = r.result;
                        if (r.result.ImgUrl) {
                            model.FileData = r.result.ImgUrl.split(',');
                        }
                        if (r.result.ImgUrl2) {
                            model.FileData2 = r.result.ImgUrl2.split(',');
                        }
                    }
                })

            },
            Save: function () {
                YDUI.dialog.confirm("", "确定要提交审核吗？", function () {
                    
                    $.post("/api/user/vd", model.ModelData.$model, function (r) {
                        if (r.error == "") {
                            YDUI.dialog.toast("提交成功，请等待管理员审核", 'none', 2000, function () {
                                history.back();
                            });
                        } else {
                            YDUI.dialog.toast(r.error, 'none', 2000);
                        }

                    })
                })

            }

        });
        avalon.ready(function () {
            if (ComFunJS.isLogin(true)) {
                model.GetTypeData();
                model.GetListData();
            }
        })

        function upload(file,s) {
            ComFunJS.fileUpload(file, function (imgs) {
                if (s == 1) {
                    model.FileData.push(imgs[0].ID);
                    model.ModelData.ImgUrl = model.FileData.toString();
                } else if (s == 2) {
                    model.FileData2.push(imgs[0].ID);
                    model.ModelData.ImgUrl2 = model.FileData2.toString();
                } else if (s == 3) {
                    model.ModelData.License = imgs[0].ID;
                }
            })
        }

    </script>
</body>

</html>
